package com.liaoban.app.helper;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;

/**
 * 进度框
 * Created by ybc on 17-9-14.
 */
public class DialogHelper {

    public static ProgressDialog getProgressDialog(Context context, int resId) {
        ProgressDialog mPd = null;
        mPd = new ProgressDialog(context);
        mPd.setCancelable(true);
        mPd.setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                // 屏蔽Search键(因为按搜索按键会被关闭)
                switch (event.getKeyCode()) {
                    case KeyEvent.KEYCODE_SEARCH:
                        return true;
                    //case KeyEvent.KEYCODE_BACK:
                        // cancelTask();
                        // cancelConfirm();
                        //return true;
                    default:
                        return false;
                }
            }
        });
        mPd.setMessage(context.getResources().getString(resId));
        return mPd;
    }

}
